﻿<?php

require('configs/include.php');

class c_updateStart extends super_controller {
	public function crearKernel()
        {
            
            $kernel= new kernel($this->post);
            if(is_empty($kernel->get('version')))
            {
                throw_exception("Debe ingresar el nombre de la version antes de continuar");

            }else if(is_empty($kernel->get('descripcion')))
            {
                throw_exception("Debe ingresar la descripcion de la version antes de continuar");

            }else {
                    $this->orm->connect();
                    $this->orm->insert_data("normal",$kernel);
                    $this->orm->close();

                    $this->type_warning = "success";
                    $this->msg_warning = "Se insertó correctamente el kernel";
                     $this->img_warning="correct.png";
                     $this->engine->assign('img_warning',$this->img_warning);
                    $this->temp_aux = 'message.tpl';

                    $this->engine->assign('type_warning',$this->type_warning);
                    $this->engine->assign('msg_warning',$this->msg_warning);
            }
        }
	public function display()
	{        
            if($_SESSION['user']['type'] == "lider"){
                $varAux=$this->gvar['n_index']." -> ".$this->gvar['n_update'];
		$this->engine->assign('ubicationPath',$varAux);
		$this->engine->display('header.tpl');
                $this->engine->display($this->temp_aux);
		$this->engine->display('updateStart.tpl');
		$this->engine->display('footer.tpl');
            }else{
                $this->engine->display('header.tpl');
                $this->engine->display('sinPermisos.tpl');
                $this->engine->display('footer.tpl');
            }
	}
	
	public function run()
	{   
            try {
                if (isset($this->get->option)){$this->{$this->get->option}();}
            }
            catch (Exception $e){
			$this->error=1; $this->msg_warning=$e->getMessage();
                        $this->img_warning="incorrect.png";
			$this->engine->assign('type_warning',$this->type_warning);
			$this->engine->assign('msg_warning',$this->msg_warning);
                        $this->engine->assign('img_warning',$this->img_warning);
			$this->temp_aux = 'message.tpl';
		}   
		$this->display();
	}
}

$call = new c_updateStart();
$call->run();

?>